package com.oig.sys.workflow.entity;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
import java.io.Serializable;


/**
 * @author wuxl
 * 定时任务配置
 */
@Getter
@Setter
@ToString
@Entity
@Table(name = "tb_cron_job")
@EntityListeners({AuditingEntityListener.class})
public class TbCronJob implements Serializable {

	/**
	 */
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name = "id", nullable = false)
	private Integer id;

	/**
	 */
	@Column(name = "job_name")
	private String jobName;

	/**
	 * 1-HTTP
	 */
	@Column(name = "job_type")
	private String jobType;


	/**
	 * 是否启动 0-未启动 1-启动
	 */
	@Column(name = "enable")
	private String enable;

	/**
	 * 定时任务时配置执行计划cron表达式
	 */
	@Column(name = "schedule_cron")
	private String scheduleCron;

	/**
	 * http:json配置 {"url":"执行接口","method":"get","header":[{"name":"","value":""}],"body":{}}
	 */
	@Column(name = "source_cfg")
	private String sourceCfg;

	/**
	 */
	@Column(name = "status")
	private String status;



	/**
	 * 1-通知 2-webHook 多个可用数组
	 */
	@Column(name = "finish_opts")
	private String finishOpts;


	/**
	 */
	@Column(name = "web_hook")
	private String webHook;

	/**
	 */
	@Column(name = "notify_title")
	private String notifyTitle;

	/**
	 * 通知内容格式
	 */
	@Column(name = "notify_content")
	private String notifyContent;

	/**
	 * 消息类型 01-定向通知 02-群消息
	 */
	@Column(name = "notify_type")
	private String notifyType;
	/**
	 * 推送渠道id
	 */
	@Column(name = "push_channel_id")
	private Integer pushChannelId;
	/**
	 * 推送机器人（渠道名称）
	 */
	@Column(name = "push_channel_name")
	private String pushChannelName;


	/**
	 * 01-租户全员 02-部门 03-人员
	 */
	@Column(name = "receiver_type")
	private String receiverType;

	/**
	 * 根据receiver_type 来，如果type=01，为租户id，找到该租户下所有人员插入receiver表  如果type=02，为部门id，找到改部门下所有人员插入receiver表 如果type=03，发给指定人员列表， dto有接收者idList
	 */
	@Column(name = "receiver_id")
	private Integer receiverId;

	/**
	 */
	@Column(name = "receiver_name")
	private String receiverName;

	/**
	 */
	@Column(name = "notify_res_file")
	private String notifyResFile;

	/**
	 */
	@CreatedBy
	@Column(name = "create_user_id")
	private Integer createUserId;

	/**
	 */
	@Column(name = "create_user_name")
	private String createUserName;

	/**
	 */
	@CreatedDate
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time")
	private java.util.Date createTime;

	/**
	 */
	@LastModifiedBy
	@Column(name = "last_update_id")
	private Integer lastUpdateId;

	/**
	 */
	@Column(name = "last_update_name")
	private String lastUpdateName;

	/**
	 */
	@LastModifiedDate
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "last_update_time")
	private java.util.Date lastUpdateTime;

	/**
	 */
	@Version
	@Column(name = "version")
	private Integer version;

	/**
	 */
	@Column(name = "tenant_id")
	private Integer tenantId;

	/**
	 */
	@Column(name = "tenant_name")
	private String tenantName;
}
